#!/usr/bin/python

import sys

def reverseSortHash(someHash):
    values = {}
    resultList = []
    
    for eachItem in someHash:
        if(values.has_key(someHash[eachItem]) == False):
            values[someHash[eachItem]] = []
            values[someHash[eachItem]].append(eachItem)
            
    listValues = values.keys()
    listValues.sort()
    listValues.reverse()
    
    for eachValue in listValues:
        for eachItem in values[eachValue]:
            resultList.append(eachItem)

    return resultList

def getPMIScore(n,a,c):
    return float(n)/(a*c)


for eachLine in sys.stdin:
    eachLine = eachLine.strip()
    n = int(eachLine.split("\t")[len(eachLine.split("\t"))-1])
    a = int(eachLine.split("\t")[len(eachLine.split("\t"))-2])
    art_name = eachLine.split("\t")[0]
    categories = eachLine.split("\t")[1:len(eachLine.split("\t"))-2]

    pmiHash = {}
    resultString = ""
    
    for eachCategory in categories:
        cat_name = eachCategory.split(":")[:len(eachCategory.split(":"))-1]
        cat_name = ":".join(cat_name)
        c = int(eachCategory.split(":")[len(eachCategory.split(":"))-1])
        pmiHash[cat_name] = getPMIScore(n,a,c)

    rankedList = reverseSortHash(pmiHash)
    resultString = art_name
    
    for eachCat in rankedList:
        resultString += "\t"+eachCat+":"+str(pmiHash[eachCat])

    print resultString
    
